package main;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import rtu.re_3;
import rtu.rtu_Classify;
import rtu.rtu_Classify03;
import GUI.equipmentGUI;
import GUI.gardenGUI;
import dao.MoistureDao;
import dao.equipmentDao;
import dao.hatchwayDao;
import dao.modelDao;
import dao.senseDeviceDao;
import entity.Equipment;
import entity.Hatchway;
import entity.Model;
import entity.SenseDevice;


public class Main {
	
	public static boolean setfinish = false;
	private	static int com_many = 0, sensorcom_num1, sensorcom_num2, sensorcom_num3, eth_many = 0;
	private static ArrayList<Hatchway> rtuInfor=new ArrayList<Hatchway>();
	private static ArrayList<Model>  model=new ArrayList<Model>();
	private static ArrayList<SenseDevice> senseDevice=new ArrayList<SenseDevice>();
	
	public static void main(String args[]){

		model=modelDao.ModelInformation();
		rtuInfor=hatchwayDao.rtuInformation();
		senseDevice=senseDeviceDao.SenseDevicelInformation();
		
		equipmentDao.EquipmentInformation();
	//	MoistureDao.moistureInformation();
		gardenGUI frame1=new gardenGUI();
		frame1.setVisible(true);
		while(true){
			if(setfinish){
							frame1.dispose();//���ؽ���
							equipmentGUI frame2=new equipmentGUI();
							frame2.setVisible(true);
							frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
							rtu();
							break;
						}
					}
		}
	
	private static void rtu() {
		com_many = rtuInfor.size();//com������
		if (com_many != 0) {					
//			for(int i =0; i<com_many ; i++){
//				new rtu_Classify01(rtuInfor.get(i),model,senseDevice);
//			}
			switch (com_many) {
			case 1: {
				new rtu_Classify(rtuInfor.get(0),model,senseDevice);
				break;
				}
			case 2: {
				
				new rtu_Classify03(rtuInfor.get(0),model,senseDevice);
				
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				new rtu_Classify03(rtuInfor.get(1),model,senseDevice);
				break;
				}
			}
		
		}
		System.out.println("  "+"串口个数：  "+com_many);
	}
}

	
	

